package com.vint.mi;


/**
 * 擦黑板
 */
public class Mi77 {
    private static  long[] baseE = {1,11,111,1111,11111,111111,1111111,11111111,111111111L,1111111111L,11111111111L,111111111111L,1111111111111L,11111111111111L,111111111111111L,1111111111111111L,11111111111111111L};
    private static String solution(String line){
        long l = Long.parseLong(line);
        long src = l;
        int end = 0;
        for(int i = 0; i<17; i++){
            if(l<baseE[i]){
               end = i - 1;
               break;
            }
        }

        long sum  = 0;
        while (l!=0){
            sum = sum * 10 + l / baseE[end];
            l = l % baseE[end];
            end --;
        }
        if(end!=-1){
            sum *= Math.pow(10,end+1);
        }
        long ret = sum;
        long check = sum;
        //反向验证一下
        while(sum!=0){
            check += sum / 10;
            sum = sum / 10;
        }
        if(check==src){
            return ret+"";
        }else {
            return "-1";
        }

    }
    public static void main(String[] args) {
        System.out.println(solution("905"));
        System.out.println(solution("11"));
        System.out.println(solution("12"));
        System.out.println(solution("10"));
        System.out.println(solution("565"));
    }
}
